<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<title>SemOpt: src/Boundcond.cpp Source File</title>

<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
</script>


</head>
<body>
<div id="top"><!-- do not remove this div! -->


<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  
  
  <td style="padding-left: 0.5em;">
   <div id="projectname">SemOpt
   &#160;<span id="projectnumber">0.2alpha5-SCC</span>
   </div>
   
  </td>
  
  
  
 </tr>
 </tbody>
</table>
</div>

<!-- Generated by Doxygen 1.7.6.1 -->
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
      <li><a href="globals.html"><span>File&#160;Members</span></a></li>
    </ul>
  </div>
</div>
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
  initNavTree('Boundcond_8cpp.html','');
</script>
<div id="doc-content">
<div class="header">
  <div class="headertitle">
<div class="title">src/Boundcond.cpp</div>  </div>
</div><!--header-->
<div class="contents">
<div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="preprocessor">#include &quot;Boundcond.h&quot;</span>
<a name="l00002"></a>00002 
<a name="l00003"></a>00003 Boundcond::Boundcond() {}
<a name="l00004"></a>00004 Boundcond::~Boundcond() {}
<a name="l00005"></a>00005 
<a name="l00006"></a>00006 <span class="comment">/*      Nella chiamata si ha A = G; B = S[i]; C = {e}</span>
<a name="l00007"></a>00007 <span class="comment">        O è il sottoinsieme dei nodi di B attaccati da nodi in C</span>
<a name="l00008"></a>00008 <span class="comment">        I è il sottoinsieme dei nodi di B\O che</span>
<a name="l00009"></a>00009 <span class="comment">                non subiscono attacchi da parte di nodi in A esterni a B</span>
<a name="l00010"></a>00010 <span class="comment">                _xor_</span>
<a name="l00011"></a>00011 <span class="comment">                subiscono eventuali attacchi solo da parte di nodi che</span>
<a name="l00012"></a>00012 <span class="comment">                        sono contenuti in A ma non in (B join C)</span>
<a name="l00013"></a>00013 <span class="comment">                        _and_</span>
<a name="l00014"></a>00014 <span class="comment">                        sono attaccati da nodi in C</span>
<a name="l00015"></a>00015 <span class="comment">*/</span>
<a name="l00016"></a>00016 <span class="keywordtype">void</span> Boundcond::doBoundcond( <a class="code" href="classSetArguments.html" title="Class encompassing a set of arguments.">SetArguments</a>* A, <a class="code" href="classSetArguments.html" title="Class encompassing a set of arguments.">SetArguments</a>* B, <a class="code" href="classSetArguments.html" title="Class encompassing a set of arguments.">SetArguments</a>* C, <a class="code" href="classSetArguments.html" title="Class encompassing a set of arguments.">SetArguments</a>* O, <a class="code" href="classSetArguments.html" title="Class encompassing a set of arguments.">SetArguments</a>* I) {
<a name="l00017"></a>00017 
<a name="l00018"></a>00018         <span class="comment">// O è il sottoinsieme dei nodi di B attaccati da nodi in C</span>
<a name="l00019"></a>00019         O = B-&gt;<a class="code" href="classSetArguments.html#a8f48fd9f7b627db762d4fc2621160853" title="Get the arguments in the caller set which are attacked by at least one node in attackers.">getSubsetAttackedBy</a>(C);
<a name="l00020"></a>00020         B-&gt;<a class="code" href="classSetArguments.html#a80e626de391cabfc0a20da509c328055" title="Setmisun.">setminus</a>(O, I);
<a name="l00021"></a>00021 <span class="preprocessor">        #ifdef DEBUG_BOUNDCOND</span>
<a name="l00022"></a>00022 <span class="preprocessor"></span>                cout &lt;&lt; <span class="stringliteral">&quot;init: O = &quot;</span>&lt;&lt;endl; O-&gt;<a class="code" href="classSetArguments.html#a97ce4b4815433f7c573a5922eaec190d" title="per ogni nodo del grafo, stampa l&#39;insieme dei suoi nodi attaccanti e di quelli attaccati.">printNodeRelations</a>();
<a name="l00023"></a>00023                 cout &lt;&lt; <span class="stringliteral">&quot;init: I = &quot;</span>&lt;&lt;endl; I-&gt;<a class="code" href="classSetArguments.html#a97ce4b4815433f7c573a5922eaec190d" title="per ogni nodo del grafo, stampa l&#39;insieme dei suoi nodi attaccanti e di quelli attaccati.">printNodeRelations</a>();
<a name="l00024"></a>00024 <span class="preprocessor">        #endif</span>
<a name="l00025"></a>00025 <span class="preprocessor"></span>        <span class="comment">// I = { n in B\O | n notin (A\B).attacks xor n notin (A\((A\(BorC))and C.attacks)).attacks = X.attacks }</span>
<a name="l00026"></a>00026         <a class="code" href="classSetArguments.html" title="Class encompassing a set of arguments.">SetArguments</a>* firstConditionSet;  <span class="comment">// (A\B).attacks</span>
<a name="l00027"></a>00027         <a class="code" href="classSetArguments.html" title="Class encompassing a set of arguments.">SetArguments</a>* secondConditionSet; <span class="comment">// (A\((A\(BorC))and C.attacks)).attacks</span>
<a name="l00028"></a>00028         <a class="code" href="classSetArguments.html" title="Class encompassing a set of arguments.">SetArguments</a>* temp1 = <span class="keyword">new</span> <a class="code" href="classSetArguments.html" title="Class encompassing a set of arguments.">SetArguments</a>(), * temp2 = <span class="keyword">new</span> <a class="code" href="classSetArguments.html" title="Class encompassing a set of arguments.">SetArguments</a>(), * temp3 = <span class="keyword">new</span> <a class="code" href="classSetArguments.html" title="Class encompassing a set of arguments.">SetArguments</a>();
<a name="l00029"></a>00029 
<a name="l00030"></a>00030         A-&gt;<a class="code" href="classSetArguments.html#a80e626de391cabfc0a20da509c328055" title="Setmisun.">setminus</a>(B, temp1);
<a name="l00031"></a>00031 <span class="preprocessor">        #ifdef DEBUG_BOUNDCOND</span>
<a name="l00032"></a>00032 <span class="preprocessor"></span>                cout &lt;&lt; <span class="stringliteral">&quot;0:temp1 = A\\B = &quot;</span> &lt;&lt; *temp1 &lt;&lt; endl;
<a name="l00033"></a>00033 <span class="preprocessor">        #endif</span>
<a name="l00034"></a>00034 <span class="preprocessor"></span>
<a name="l00035"></a>00035         firstConditionSet = temp1-&gt;<a class="code" href="classSetArguments.html#ab7c0f1063978299f753e91e11f0818ef">getAllAttacks</a>();
<a name="l00036"></a>00036 <span class="preprocessor">        #ifdef DEBUG_BOUNDCOND</span>
<a name="l00037"></a>00037 <span class="preprocessor"></span>                cout &lt;&lt; <span class="stringliteral">&quot;FIRST | nodi(anche di A\\B) attaccati da A\\B: &quot;</span> &lt;&lt; *firstConditionSet &lt;&lt; endl;
<a name="l00038"></a>00038 <span class="preprocessor">        #endif</span>
<a name="l00039"></a>00039 <span class="preprocessor"></span>
<a name="l00040"></a>00040         temp1-&gt;<a class="code" href="classSetArguments.html#a0de309ba2427eb3dce2f8ca93bb078e4" title="removes all the pointers of Arguments inside this set.">clean</a>(); <span class="comment">//TODO qua van forse dei delete temp1 ?</span>
<a name="l00041"></a>00041 <span class="preprocessor">        #ifdef DEBUG_BOUNDCOND</span>
<a name="l00042"></a>00042 <span class="preprocessor"></span>                cout &lt;&lt; <span class="stringliteral">&quot;CLEAN: A = &quot;</span> &lt;&lt; *A &lt;&lt; <span class="stringliteral">&quot;, B = &quot;</span> &lt;&lt; *B &lt;&lt; <span class="stringliteral">&quot;, A\\B = temp1 = &quot;</span> &lt;&lt; *temp1 &lt;&lt; <span class="stringliteral">&quot;: &quot;</span> &lt;&lt; endl;
<a name="l00043"></a>00043 <span class="preprocessor">        #endif</span>
<a name="l00044"></a>00044 <span class="preprocessor"></span>        B-&gt;<a class="code" href="classSetArguments.html#a1b532abb70dde9aa99148be16ed59af1" title="Perform the union of two SetArguments.">merge</a>(C, temp1);                             <span class="comment">// temp1 = B or C</span>
<a name="l00045"></a>00045 <span class="preprocessor">        #ifdef DEBUG_BOUNDCOND</span>
<a name="l00046"></a>00046 <span class="preprocessor"></span>                cout &lt;&lt; <span class="stringliteral">&quot;1:temp1 = B or C = &quot;</span> &lt;&lt; *temp1 &lt;&lt; endl;
<a name="l00047"></a>00047 <span class="preprocessor">        #endif</span>
<a name="l00048"></a>00048 <span class="preprocessor"></span>        A-&gt;<a class="code" href="classSetArguments.html#a80e626de391cabfc0a20da509c328055" title="Setmisun.">setminus</a>(temp1, temp2);              <span class="comment">// temp2 = A \ (B or C)</span>
<a name="l00049"></a>00049 <span class="preprocessor">        #ifdef DEBUG_BOUNDCOND</span>
<a name="l00050"></a>00050 <span class="preprocessor"></span>                cout &lt;&lt; <span class="stringliteral">&quot;2:temp2 = A \\ (B or C) = &quot;</span> &lt;&lt; *temp2 &lt;&lt; endl;
<a name="l00051"></a>00051 <span class="preprocessor">        #endif</span>
<a name="l00052"></a>00052 <span class="preprocessor"></span>        temp1-&gt;<a class="code" href="classSetArguments.html#a0de309ba2427eb3dce2f8ca93bb078e4" title="removes all the pointers of Arguments inside this set.">clean</a>();
<a name="l00053"></a>00053         temp1 = C-&gt;<a class="code" href="classSetArguments.html#ab7c0f1063978299f753e91e11f0818ef">getAllAttacks</a>();                     <span class="comment">// temp1 = C.attacks</span>
<a name="l00054"></a>00054 <span class="preprocessor">        #ifdef DEBUG_BOUNDCOND</span>
<a name="l00055"></a>00055 <span class="preprocessor"></span>                cout &lt;&lt; <span class="stringliteral">&quot;3:temp1 = C.attacks &quot;</span> &lt;&lt; *temp1 &lt;&lt; endl;
<a name="l00056"></a>00056 <span class="preprocessor">        #endif</span>
<a name="l00057"></a>00057 <span class="preprocessor"></span>
<a name="l00058"></a>00058         temp1-&gt;<a class="code" href="classSetArguments.html#ae6761b6c360e440de55c2060ae70981c" title="Intersect this set the `other` set and write the result in `res`.">intersect</a>(temp2, temp3); <span class="comment">// temp3 = temp1 and temp2   QUI MUORE</span>
<a name="l00059"></a>00059 <span class="preprocessor">        #ifdef DEBUG_BOUNDCOND</span>
<a name="l00060"></a>00060 <span class="preprocessor"></span>                cout &lt;&lt; <span class="stringliteral">&quot;4:temp3 = temp1 and temp2 = &quot;</span> &lt;&lt; *temp3 &lt;&lt; endl;
<a name="l00061"></a>00061 <span class="preprocessor">        #endif</span>
<a name="l00062"></a>00062 <span class="preprocessor"></span>        temp1-&gt;<a class="code" href="classSetArguments.html#a0de309ba2427eb3dce2f8ca93bb078e4" title="removes all the pointers of Arguments inside this set.">clean</a>();
<a name="l00063"></a>00063 
<a name="l00064"></a>00064         A-&gt;<a class="code" href="classSetArguments.html#a80e626de391cabfc0a20da509c328055" title="Setmisun.">setminus</a>(temp3, temp1);              <span class="comment">// temp1 = A \ temp3</span>
<a name="l00065"></a>00065 <span class="preprocessor">        #ifdef DEBUG_BOUNDCOND</span>
<a name="l00066"></a>00066 <span class="preprocessor"></span>                cout &lt;&lt; <span class="stringliteral">&quot;5:temp1 = X = A \\ temp3 = &quot;</span> &lt;&lt; *temp1 &lt;&lt; endl;
<a name="l00067"></a>00067 <span class="preprocessor">        #endif</span>
<a name="l00068"></a>00068 <span class="preprocessor"></span>
<a name="l00069"></a>00069         secondConditionSet = temp1-&gt;<a class="code" href="classSetArguments.html#ab7c0f1063978299f753e91e11f0818ef">getAllAttacks</a>();
<a name="l00070"></a>00070 <span class="preprocessor">        #ifdef DEBUG_BOUNDCOND</span>
<a name="l00071"></a>00071 <span class="preprocessor"></span>                cout &lt;&lt; <span class="stringliteral">&quot;SECOND | nodi(anche di X) attaccati da X: &quot;</span> &lt;&lt; *secondConditionSet &lt;&lt; endl;
<a name="l00072"></a>00072 <span class="preprocessor">        #endif</span>
<a name="l00073"></a>00073 <span class="preprocessor"></span>
<a name="l00074"></a>00074         <span class="keywordflow">for</span>(<a class="code" href="classSetArgumentsIterator.html" title="Class defining a const iterator for the elements of a set of arguments.">SetArgumentsIterator</a> it=I-&gt;<a class="code" href="classSetArguments.html#aaee058feaed861edf27739fa04f374ef" title="Begin of the iterator for this set of arguments.">begin</a>(); it!=I-&gt;<a class="code" href="classSetArguments.html#a551272d71c803f64efc155b04f41e775" title="End of the iterator for this set of arguments.">end</a>(); it++) {
<a name="l00075"></a>00075 <span class="preprocessor">                #ifdef DEBUG_BOUNDCOND</span>
<a name="l00076"></a>00076 <span class="preprocessor"></span>                        cout &lt;&lt; endl &lt;&lt; <span class="stringliteral">&quot;for su I di boundcond: nodo = &quot;</span> &lt;&lt; (*it)-&gt;print() &lt;&lt; endl;
<a name="l00077"></a>00077 <span class="preprocessor">                #endif</span>
<a name="l00078"></a>00078 <span class="preprocessor"></span>                <span class="keywordflow">if</span>( firstConditionSet-&gt;<a class="code" href="classSetArguments.html#a0be6b8f77319a6aec9127eccd3ee43d9" title="Check whether or not an argument exists in this set.">exists</a>(*it)<span class="comment">/* nodo non subisce attacchi da nodi di A\B */</span>)
<a name="l00079"></a>00079                         <span class="keywordflow">continue</span>;
<a name="l00080"></a>00080                 <span class="keywordflow">if</span>( secondConditionSet-&gt;<a class="code" href="classSetArguments.html#a0be6b8f77319a6aec9127eccd3ee43d9" title="Check whether or not an argument exists in this set.">exists</a>(*it)<span class="comment">/* nodo.attaccanti sono SOLO in A\(BorC)andC */</span>)
<a name="l00081"></a>00081                         <span class="keywordflow">continue</span>;
<a name="l00082"></a>00082 <span class="preprocessor">                #ifdef DEBUG_BOUNDCOND</span>
<a name="l00083"></a>00083 <span class="preprocessor"></span>                        cout &lt;&lt; <span class="stringliteral">&quot;removing node from I.&quot;</span> &lt;&lt; endl;
<a name="l00084"></a>00084 <span class="preprocessor">                #endif</span>
<a name="l00085"></a>00085 <span class="preprocessor"></span>                I-&gt;<a class="code" href="classSetArguments.html#a11b8009ff9cd0961731eac8ee95c4b55" title="Remove an argument from this set.">remove</a>(*it);
<a name="l00086"></a>00086         }
<a name="l00087"></a>00087 <span class="preprocessor">        #ifdef DEBUG_BOUNDCOND</span>
<a name="l00088"></a>00088 <span class="preprocessor"></span>                cout&lt;&lt; <span class="stringliteral">&quot;FINAL BOUNDCOND: I = &quot;</span> &lt;&lt; *I &lt;&lt; endl;
<a name="l00089"></a>00089 <span class="preprocessor">        #endif</span>
<a name="l00090"></a>00090 <span class="preprocessor"></span>        <span class="keyword">delete</span> temp1;
<a name="l00091"></a>00091         <span class="keyword">delete</span> temp2;
<a name="l00092"></a>00092         <span class="keyword">delete</span> temp3;
<a name="l00093"></a>00093         <span class="keyword">delete</span> firstConditionSet;
<a name="l00094"></a>00094         <span class="keyword">delete</span> secondConditionSet;
<a name="l00095"></a>00095 }
<a name="l00096"></a>00096 
</pre></div></div><!-- contents -->
</div>
  <div id="nav-path" class="navpath">
    <ul>
      <li class="navelem"><b>Boundcond.cpp</b>      </li>

    <li class="footer">Generated on Fri Jan 17 2014 11:47:51 for SemOpt by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.6.1 </li>
   </ul>
 </div>


</body>
</html>
